#!/usr/bin/python
#  This is part of the Scopia data visualization example collection
#
#
#  Copyright (C) 2008  Scopia Visual Interfaces Systems 
#                      http://www.scopia.es
#
#  author: Alejandro Conty
#  contributors:
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

import scopiavf.engine.glcontext as glcontext
import sys
import math
import time
from style.default import Style
from numpy import *
from scopiavf.engine.rendertree import *

import nodes

ESCAPE = '\033'

class Manager( glcontext.GlContext ):

    def __init__( self, w, h):
        glcontext.GlContext.__init__(self, w, h )
        self.timers = []
        self.style = Style( self )
        tree = nodes.LiveTreeNode(self, self.style)
        proj = RenderOrthoNode(self, self.style, tree, (0,0), (1, 1) )
        #proj = RenderRotCameraNode(self, self.style, tree, (0,0,0), 1.7, math.pi*0.25 )
        self.root = RenderViewportNode(self, self.style, proj, 0, 0, 1, 1)
        #proj.startRotation(0.05)


    def display(self):
        "Display function"
        self.depthTest( False )
        self.root.render()

    def keyboard(self, key, x, y):
        if key == ESCAPE:
            print 'Done'
            sys.exit()
    
